/*
*	地图Model
*	缩放级、当前中心点、
*/
var MapModel = {
	//缩放级别[5,7,9]	分别对应全国图、省级图、市级海量点图
	zoom : 5,
	//当前视图和数据Model对应的日期时间戳(13位)
	date : "",
	//当前视图和数据Model对应的省份
	province : "",
	//当前视图和数据Model对应的城市
	city : "",
	center:[100.139152,37.392744],
	style:[
		{"featureType": "background","elementType": "all","stylers": {"color": "#004a87"} },
		{"featureType": "road","elementType": "all","stylers": {"visibility": "off"} },
		{"featureType": "water","elementType": "all","stylers": {"color": "#072f4e"} },
	    {"featureType": "administrative","elementType": "all","stylers": {"visibility": "off"} },
	    {"featureType": "poi","elementType": "all","stylers": {"visibility": "off"} }
	],
	//获取噪声db对应的颜色色值
	getDBColor : function(number){
		if(number>=75){
			return "#FF7A32";
		}
		else if( number<75 && number>= 72 ){
			return "#EDA065";
		}
		else if( number<72 && number>= 70 ){
			return "#66DEF8";
		}
		else if( number<70 && number>= 65 ){
			return "#0AC2FF";
		}
		else{
			return "#1D80CA";
		}
	}
};





/*
*	国家级数据Model
*	source格式：[["黑龙江省",56],["辽宁省",67]]
*	cache格式：{"1435998194000":[["黑龙江省",56],["辽宁省",67]],"14340092334000":[["黑龙江省",56],["辽宁省",67]]}
*/
var CountryModel = {
	//当前数据源
	source : [],
	//国家级数据缓存
	cache : {},
	//添加函数,更新source&写入cache,更新MapModule.province
	add: function (_date, _source) {
	    //console.log(_source);
		this.source = _source;
		this.cache[_date] = _source;
	},
	//替换函数,从缓存中读取_date数据，更新source
	replace : function(_date){
		this.source = this.cache[_date];
	},
	//检查某日的数据是否已经存在cache中
	checkCache : function(_date){
		if( this.cache[_date] == undefined ){
			return false;
		}
		else{
			return true;
		}
	},
	//获取当前source数据中的某省数据
	getProvinceData : function(name){
		var i,j;
		for(i=0;i<this.source.length;i++){
			if( this.source[i][0] == name  ){
				return this.source[i][1];
			}
		}
		return false;
	}
}





/*
*	省级数据Model
*	source格式：[["大连市",56],["沈阳市",67]]
*	cache格式： {"黑龙江省":{
*					"1435998194000":[["沈阳市",67],["大连市",71],["鞍山市",63]],
*					"1435237619000":[["沈阳市",69],["大连市",71],["鞍山市",61]]
*					}
*				}
*/
var ProvinceModel = {
	//当前数据源
	source : [],
	//省级数据缓存
	cache : {},
	checkCache : function(_date){
		var result = this.cache[MapModel.province];
		if( result == undefined || result[_date] == undefined ){
			return false;
		}
		else{
			return true;
		}
	},
	add : function(_date,_source){
		this.source = _source;
		if(this.cache[MapModel.province]==undefined){
			this.cache[MapModel.province] = {};
		}
		this.cache[MapModel.province][_date] = _source;
	},
	replace : function(_date){
		this.source = this.cache[MapModel.province][_date];
	},
	getCityData : function(city_name){
		var i,j,k;
		for(i=0;i<this.source.length;i++){
			if(this.source[i][0]==city_name){
				return this.source[i][1];
			}
		}
		return false;
	}
}






/*
*	市级数据Model
*	source格式：[[121.165,38.812,56],[121.286,38.850,78],[121.496,38.935,74],[121.162,38.816,56]...]
*	市级海量点数据不做缓存
*/
var CityModel = {
	source: [],
	add : function(_source){
		this.source = _source;
	}
}